package com.winhxd.b2c.order.util;

import com.winhxd.b2c.common.domain.message.condition.MiniMsgCondition;
import com.winhxd.b2c.common.domain.message.condition.MiniTemplateData;
import com.winhxd.b2c.common.util.DateUtil;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author hjw
 * @create 2019-01-08 16:48
 **/
public class OrderUtils {

    /**
     * @author hjw
     * @date 2019/1/8 16:52
     * @param sendTime   订单发货时间
     * @param minute     订单自动收货时间
     * @Description      校验订单是否自动收货  true 自动收货时间已到  false 自动收货时间未到
     * @return
     */
    public static boolean isAutoRecive(Date sendTime, Integer minute){
        return System.currentTimeMillis() >= DateUtil.getDateAddMinute(sendTime,minute).getTime();
    }
    /** 
    * @Description: 组装模板发送消息对象
    * @Author: liuhanning 
    * @Date: 2019/1/16 16:06
    */ 
    public static MiniMsgCondition genMiniMsgCondition(String openid, String page, short msgType2C, String emphasisKeyword, MiniTemplateData... datas) {
        List<MiniTemplateData> temData = Arrays.asList(datas);
        MiniMsgCondition miniMsgCondition = new MiniMsgCondition();
        miniMsgCondition.setToUser(openid);
        miniMsgCondition.setPage(page);
        miniMsgCondition.setMsgType(msgType2C);
        miniMsgCondition.setData(temData);
        miniMsgCondition.setEmphasisKeyword(emphasisKeyword);
        return miniMsgCondition;
    }
}
